package game

import (
	"context"
	"database/sql"
	"fmt"
	"github.com/zeromicro/go-zero/core/stores/cache"
	"github.com/zeromicro/go-zero/core/stores/sqlx"
)

var _ Order1Model = (*customOrder1Model)(nil)

type (
	// Order1Model is an interface to be customized, add more methods here,
	// and implement the added methods in customOrder1Model.
	Order1Model interface {
		order1Model
		InsertTrans(ctx context.Context, tx sqlx.Session, data *Order1) (sql.Result, error)
	}

	customOrder1Model struct {
		*defaultOrder1Model
	}
)

// NewOrder1Model returns a model for the database table.
func NewOrder1Model(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) Order1Model {
	return &customOrder1Model{
		defaultOrder1Model: newOrder1Model(conn, c, opts...),
	}
}

func (m *customOrder1Model) InsertTrans(ctx context.Context, tx sqlx.Session, data *Order1) (sql.Result, error) {
	query := fmt.Sprintf("insert ignore into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, order1RowsExpectAutoSet)
	ret, err := tx.ExecCtx(ctx, query, data.Id, data.RoundId, data.Username, data.CurrencyId, data.InstId, data.GameId, data.Currency, data.IsFreeBet, data.Win, data.BetAmt, data.WinAmt, data.Payout, data.OrderTime, data.PayTime, data.OpenId, data.Status, data.Ver)
	return ret, err
}
